package com.baykalcakici.cafepicker.tasks;

import android.app.ProgressDialog;
import android.os.AsyncTask;

import com.baykalcakici.cafepicker.Main;
import com.google.common.base.Preconditions;

/**
 * Task responsible of visiting a cafe.
 */
public class VisitTask extends AsyncTask<String, Integer, String> {
  private ProgressDialog dialog;

  public VisitTask(ProgressDialog dialog) {
    this.dialog = Preconditions.checkNotNull(dialog);
  }

  @Override
  protected String doInBackground(String... params) {
    Main.cafePicker.visit(params[0]);
    return null;
  }

  @Override
  protected void onPostExecute(String value) {
    super.onPostExecute(value);
    dialog.dismiss();
  }
}
